Skip to content

Gecode 7: clang-tidy sweep - #274

Draft
zayenz wants to merge 80 commits into
feature/breaking-7-10-scoped-enumsfrom
feature/breaking-7
Draft

zayenz wants to merge 80 commits into
feature/breaking-7-10-scoped-enumsfrom
feature/breaking-7

Conversation

@zayenz

@zayenz zayenz commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

This is the final PR of the eleven-PR Gecode 7 series, and the branch that originally held all of them. What remains here is the clang-tidy sweep: 80 commits, each enabling a single check or small group of checks and fixing what it reports, so every commit passes misc/check.py lint.

Most of the commits are small and mechanical: removing (void) parameter lists, switching to nested namespaces, replacing typedef with using, adopting range-based loops, contains(), empty(), starts_with(), make_unique, and make_shared, dropping redundant casts and else after return, and matching parameter names between declarations and definitions.

A smaller set of commits makes behavioral or API-visible changes and is worth a closer look:

  • Self-assignment handling: NaryInter and NaryUnion previously dropped their free list when assigned to themselves.
  • Exceptions and destructors: enables destructor exception-escape checks (marking three false positives), derives FlatZinc::Error, AST::TypeError, and ShapeError from std::exception with what(), and updates tests that threw raw int to use std::logic_error.
  • API and safety checks: rejects reserved identifiers (allowing _GNU_SOURCE in blackbox-backend.cpp), checks for likely swapped call arguments, checks that rvalue reference parameters are moved, gives BranchPlugin a virtual destructor, and drops a default argument from a virtual function.
  • Clang static analyzer groups: enables the analyzer groups that fit Gecode (cplusplus, deadcode, nullability, optin, security, unix, valist), removes dead stores (including an unused search timer in Gist), fixes a declaration/definition name mismatch in Cutoff::geometric, and documents every remaining suppression in place.
  • FlatZinc parser and lexer: extends linting into the Bison grammar actions, Flex lexer, and parser.hh, making internal parser helpers static and isolating the free() of strdup token strings in one helper.
  • Style and check documentation: docs/code-style.md records why each excluded clang-tidy check was left off so future reviews do not have to re-investigate them, and notes that new scoped enums may use PascalCase enumerators (as in EndReason::Limit).

Three late commits fix issues that CI caught on the earlier combined branch: a stray blank line in the unary test, defining NOMINMAX in blackbox-exec.cpp after dropping parentheses around numeric_limits, and re-qualifying a matrix slice conversion for MSVC. (The calc_dff_lower_bound template parameter rename moved to #286, since main needs it too.) I left them as separate commits rather than folding them back into the sweep commits they fix.

The final two commits record the .zdev development notes for the Gecode 7 work and then remove them so they are not merged into main.

Tested at the tip on macOS: the build produces no warnings; formatting, generated-source freshness, and misc/check.py lint all pass; and check passes 569 of 569.

Stack

Merge in this order. #242, #282, #283, #241, #284, and #285 are merged. #286 targets main, and each later PR builds on the one before it so its diff shows only its own commits. The first four PRs are standalone search and random-number changes; #284 through #274 are the Gecode 7 changes split out of what used to be a single branch.

  1. Rank solutions with Space::compare in best-solution search #242 Rank solutions with Space::compare (merged)
  2. Rename the meta-search hooks to hub and spoke #282 Rename the meta-search hooks to hub and spoke (merged)
  3. Give meta search hub and spoke contexts and report why search ended #283 Hub and spoke contexts and end reasons (merged)
  4. Add extensible random generators with reproducible stream splitting #241 Splittable random generators (merged)
  5. Gecode 7: CMake-only C++23 build baseline #284 Gecode 7: build baseline (merged)
  6. Gecode 7: format the sources with LLVM 22 #285 Gecode 7: reformat (merged)
  7. Gecode 7: normalized API names, LT constants and Clang checks #286 Gecode 7: API names, LT constants, checks
  8. Gecode 7: post nothing for empty arrays #287 Gecode 7: empty arrays
  9. Gecode 7: pass large parameters by const reference #288 Gecode 7: const& parameters
  10. Gecode 7: state and assert the heap size contract #289 Gecode 7: heap contract
  11. Gecode 7: trivially copyable handles and defaulted special members #290 Gecode 7: modern classes
  12. Gecode 7: native float interval instead of Boost #291 Gecode 7: native float interval
  13. Gecode 7: bug fixes and Doxygen warnings #292 Gecode 7: bug fixes and Doxygen
  14. Gecode 7: scoped enums and descriptive constant names #293 Gecode 7: scoped enums
  15. Gecode 7: clang-tidy sweep #274 Gecode 7: clang-tidy sweep ← this PR
  16. Add down_cast and a typed Space::clone #294 down_cast and a typed Space::clone

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Enable modernize-use-ranges. The cumulatives test sorts by position through a projection, since std::ranges::sort needs more than the operator< that Event had.
Enable modernize-use-transparent-functors.
Enable modernize-min-max-use-initializer-list.
Enable readability-non-const-parameter.
Enable readability-else-after-return.
Enable readability-simplify-boolean-expr without De Morgan rewrites, and remove a dead branch in the Gist tree builder.
Enable readability-inconsistent-declaration-parameter-name, and update the parameter references in the Doxygen comments.
Enable readability-suspicious-call-argument. Its one report is a symmetric call.
Enable modernize-concat-nested-namespaces, and generate the same form. Shallower indentation lets clang-format repack the tables in the MiniModel tests.
Enable modernize-avoid-c-style-cast.
Enable modernize-avoid-variadic-functions.
Enable cppcoreguidelines-misleading-capture-default-by-value, cppcoreguidelines-missing-std-forward, google-build-explicit-make-pair, and google-global-names-in-headers.
Enable cppcoreguidelines-no-malloc.
Enable cert-err33-c with casts to void allowed.
Enable cppcoreguidelines-rvalue-reference-param-not-moved. Only the empty branch filter and print function take an rvalue without moving it.
Enable hicpp-exception-baseclass. FlatZinc::Error, AST::TypeError, and ShapeError now provide what(), and the tests that unwind with a thrown int use std::logic_error.
Enable misc-use-internal-linkage for functions.
Enable clang-analyzer cplusplus, deadcode, nullability, optin, security, unix, and valist, except the checks that only produce false positives here. Remove the dead stores this finds, including the unused search timer in Gist.
The per-check sweeps missed these. The names in declarations and
definitions now agree, and Cutoff::geometric no longer calls its scale
base in the definition; it passed them in the right order all along.
The cumulative tests hold their usage table in a vector, which also
removes the analyzer's report on an empty allocation.
Lint stops at the first failing stage, so the grammar actions and
parser.hh were reached only once everything else passed. yyerror keeps
external linkage, because the lexer calls it, and is now declared once
in parser.hh; the other parser functions become static. Token strings
come from strdup, so one helper holds the free the check has to allow.

The windows and none blackbox sources and the headers no linted source
includes get the same namespace form, which a lint here cannot reach.
Record why each excluded check does not fit, so that a later review
starts from the reasons, and which fix-its need care. Also restore
bugprone-unused-return-value, which the switch to whole groups excluded
by mistake.
Removing the redundant parentheses around numeric_limits members in
blackbox-exec.cpp exposed them to the min and max macros of windows.h,
so define NOMINMAX as blackbox-backend.cpp does.
MSVC rejects the unqualified ArgsType in this conversion function.
@zayenz
zayenz force-pushed the feature/breaking-7 branch from 4c7a64a to 6b473d8 Compare November 26, 2026 19:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant